<?php

namespace App\Kuafu\Activity\Resources;

use App\Http\Resources\BaseResource;

class ActivityDetailResource extends BaseResource
{

    public function toArray($request): array
    {
        return [
            "id"           => $this->id,
            "brandId"      => $this->brandId,
            "status"       => $this->status,
            "shopType"     => $this->shopType,
            "name"         => $this->name,
            "type"         => $this->type,
            "startAt"      => $this->startAt,
            "endAt"        => $this->endAt,
            "description"  => $this->description,
            "limitJoinNum" => $this->limitJoinNum,
            "hasJoinNum"   => $this->hasJoinNum,
            "image"        => $this->whenLoaded(
                "activityImageRel",
                function () {
                    return $this->activityImageRel->where('type', 0)
                                                  ->sortBy('id')
                                                  ->pluck("imageUrl")
                                                  ->map("picturePath")
                                                  ->toArray();
                }
            )
        ]; // TODO: Change the autogenerated stub
    }


}
